package com.sdlh.demo.pattern.strategy;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class PaymentStrategyFactory {
    @Autowired
    private AliPay alipay;
    @Autowired
    private WeChatPay weChatPay;
    @Autowired
    private UnionPay unionPay;

    public AbstractPaymentStrategy getStrategy(int payType) {
        switch (payType) {
            case 1:
                return alipay;
            case 2:
                return weChatPay;
            case 3:
                return unionPay;
            default:
                throw new IllegalArgumentException("无效的支付类型");
        }
    }
}
